<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Document</title>
    <script src="/node_modules/react/umd/react.development.js"></script>
    <script src="/node_modules/react-dom/umd/react-dom.development.js"></script>
    <script src="/node_modules/babel-standalone/babel.min.js"></script>

</head>
<body>
    <div id="test"></div>
    <script type="text/babel">
    class Login extends React.Component{
        state = {
            username:'',
            password:''
        }
        saveusername=()=>{
            this.setState({username:event.target.value})
        }
        savepassword = ()=>{
            this.setState({password:event.target.value})
        }

        handleSubmit = ()=>{
            event.preventDefault() //阻止表单提交 
            const {username, password} = this.state
            alert(`输入的用户名是${username},密码是${password}`)
        }
        render(){
            return(
                <form action=""  onSubmit={this.handleSubmit}>
                 用户名：<input onChange={this.saveusername} type="text" name="username" />        
                 密码：<input onChange={this.savepassword}  type="password" name="password" />
                 <button>登录</button>
            </form>
            )
        }
    }
    ReactDOM.render(<Login/>,document.getElementById('test'))
    </script>
    
</body>
</html>